//
//  ZRUnloginViewController.swift
//  XJ8XWB
//
//  Created by 中二 on 2016/10/24.
//  Copyright © 2016年 中二. All rights reserved.
//

import UIKit

class ZRUnloginViewController: UIViewController {

    var isLogin:Bool =  ZRUserAccountViewModel.sharedTools.isLogin
    
    var visitorView:ZRUnloginView?
    
    override func loadView() {
        if isLogin {
            
            super.loadView()
            
            view = tableView
            
        }else {
            
            // 代表没有登录
            setupVisitorView()
            
        }
        
    }
    
    // MARK: - 设置访客视图
    private func setupVisitorView(){
        
        visitorView = ZRUnloginView()
        
        visitorView?.closure = {[weak self] in
            
            self?.loginClick()
            
        }
        
        self.view = visitorView
        
        setupNav()
        
    }
    
   @objc private func loginClick(){
        
        print("访客视图四个按钮点击")
        
        let oauthVc = ZROAViewController()
        let oauthNavC = ZRMainNavViewController(rootViewController: oauthVc)
        present(oauthNavC, animated: true) { 
            print("跳出来了")
        }
        
        
    }
    
    private func setupNav(){
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(setHighlightedImgName: nil, title: "注册", target: self, action: #selector(loginClick))
        navigationItem.rightBarButtonItem = UIBarButtonItem(setHighlightedImgName: nil, title: "登录", target: self, action: #selector(loginClick))
    
    }
    
    
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        
        
    
    }

    // MARK: - 懒加载控件
    lazy var tableView: UITableView = UITableView()
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
